package charpter14.lynx;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.security.Principal;

public class Twenty {
    public static void main(String[] args) {
		if (args.length != 1){
			System.out.println("Usage: Twenty classname");
			System.exit(0);
		}
		try {
			Class<?> claz = Class.forName(args[0]);
			System.out.println(claz.getPackage().toString());
			System.out.println("getname:"+claz.getName());
			System.out.println("getSimpleName:"+claz.getSimpleName());
			System.out.println("getCanonicalName:"+claz.getCanonicalName());
			
			System.out.println("\nAnnotations:");
			for (Annotation annotation: claz.getAnnotations()) {
				System.out.println(annotation.toString());
			}
			System.out.println("end of annotations.");
			
			System.out.println("\nDeclaredFields:");
			for (Field field: claz.getDeclaredFields()) {
				System.out.println(field.toString());
			}
			System.out.println("end of DeclaredFields.");

			System.out.println("\nDeclaredMethods:");
			for (Method method: claz.getDeclaredMethods()) {
				System.out.println(method.toString());
			}
			System.out.println("end of DeclaredMethods.");
			try {
				System.out.println(claz.getProtectionDomain().getCodeSource().toString());	
			} catch (Exception e) {
			}
			
			
			System.out.println("\ngetProtectionDomain().getPrincipals():");
			for (Principal principal: claz.getProtectionDomain().getPrincipals()) {
				System.out.println(principal.toString());
			}
			System.out.println("end of getProtectionDomain().getPrincipals().");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}
}